﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OperationPlugins.Models;
using OperationPlugins.Validators.DataAnnotations;

namespace Demo.Model
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
    public class OmaTableAttribute : TableAttribute
    {
        public OmaTableAttribute(string name) : base(name)
        {
        }
    }


    public interface IBusinessEntity2
    {
        string Status { set; get; }

        Dictionary<List<string>, short> AnnaArvo(bool eka, string toka, Dictionary<int, short> kolmas, out string neljas);

        void TeeJotakin();

        void TeeJotakin2(ref int muuttuja, params string[] arvot);

        void TeeJotakin3(int x, string s = null);
    }

    public interface IBusinessEntity
    {
        string Status { set; get; }

        IDictionary<string, IDictionary<int, DateTime>> Sanakirja { set; get; } 
    }

    [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
    public class OmaTyyppiAttribute : Attribute
    {
        public OmaTyyppiAttribute(Type t)
        {
        }
        public OmaTyyppiAttribute(string s)
        {
        }

        public OmaTyyppiAttribute(params double[] s)
        {
        }
    }

    [OmaTyyppi(typeof(DateTime))]
    [OmaTyyppi("Moi")]
    [OmaTable("Employee", Schema = "OperationPluginsDemo")]
    [UsePluginValidators]
    public interface IEmployee : IBusinessEntity, IBusinessEntity2, INotifyPropertyChanged
    {
        /// <summary>
        /// Id
        /// </summary>
        [Key]
        [Required]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Name = "#")]
        [OmaTyyppi(1.11, 3.111, 31313.1111)]
        [OmaTyyppi(new Double[3] { 1.11, 3.111, 31313.1111 })]
        int EmployeeId { set; get; }

        /// <summary>
        /// Last name
        /// </summary>
        [Required(AllowEmptyStrings = false)]
        [StringLength(100)]
        [Display(Name = "Last name")]
        string LastName { set; get; }

        /// <summary>
        /// First name
        /// </summary>
        [Required(AllowEmptyStrings = false)]
        [StringLength(100)]
        [Display(Name = "First name")]
        string FirstName { set; get; }

        /// <summary>
        /// Title of courtesy
        /// </summary>
        [StringLength(100)]
        [Display(Name = "Title of courtesy")]
        string TitleOfCourtesy { set; get; }

        /// <summary>
        /// Title
        /// </summary>
        [Required(AllowEmptyStrings = false)]
        [StringLength(100)]
        [Display(Name = "Title")]
        string Title { set; get; }

        /// <summary>
        /// Birth date
        /// </summary>
        [Required]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
        [Display(Name = "Birth date")]
        DateTime BirthDate { set; get; }

        /// <summary>
        /// Hire date
        /// </summary>
        [Required]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
        [Display(Name = "Hire date")]
        DateTime HireDate { set; get; }

        /// <summary>
        /// Salary (per year)
        /// </summary>
        [Range(0, double.MaxValue)]
        [Display(Name = "Salary (€)")]
        decimal Salary { set; get; }

        /// <summary>
        /// Annual bonus
        /// </summary>
        [Range(0, double.MaxValue)]
        [Display(Name = "Annual bonus (€)")]
        [PropertyValueDependsOn(typeof(IEmployee), "Salary")]
        decimal AnnualBonus { set; get; }

        /// <summary>
        /// Company e-mail address
        /// </summary>
        [Required]
        [StringLength(100)]
        [Display(Name = "Company e-mail")]
        string CompanyEmail { set; get; }

        /// <summary>
        /// Company network username
        /// </summary>
        [StringLength(32)]
        [Display(Name = "Company network username")]
        string CompanyNetworkUsername { set; get; }

        /// <summary>
        /// Company network password
        /// </summary>
        [StringLength(32)]
        [Display(Name = "Company network password")]
        string CompanyNetworkPassword { set; get; }
    }
}
